package com.xmut.mall.manager.controller;

import com.xmut.mall.manager.annotation.CheckJwt;
import com.xmut.mall.manager.entity.MemberEntity;
import com.xmut.mall.manager.service.MemberService;
import com.xmut.mall.manager.utils.RespBean;
import com.xmut.mall.manager.vo.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("manager/member")
public class MemberController {

    @Autowired
    private MemberService memberService;

//    @PostMapping("/saveMember")
//    public RespBean saveMember(@RequestBody MemberEntity entity){
//        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
//        entity.setPassword(encoder.encode(entity.getPassword()));
//        memberService.save(entity);
//        return RespBean.success("生成成功");
//    }

    /**
     * 管理员后台登录
     * @param vo
     * @return
     */
    @PostMapping("/managerLogin")
    public RespBean managerLogin(@RequestBody LoginVo vo){
        return memberService.managerLogin(vo);
    }
}
